<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mdl_Rmis_Research extends CI_Model {

    public function __construct(){
        parent::__construct();
        $this->load->database();
    }
    
    public function get_research_details(){
        $sql = "SELECT r.Res_ID, r.Res_Title, r.Res_Abstract, r.Res_Department, r.Res_Status, r.Res_Type, r.Res_Date_Uploaded
            FROM research r
            WHERE r.Res_Status = '1'
            ORDER BY r.Res_Date_Uploaded
        ";
        $query = $this->db->query($sql);

        if($query->num_rows() > 0)
            return $query->result_array();
        return 0;
    }

    public function get_research_authors($Res_ID){
        $sql = "SELECT CONCAT( faculty_member.LastName,  ',', faculty_member.FirstName,  ' ', faculty_member.MiddleName ) AS \"Name\"
                FROM faculty_member
                INNER JOIN account_research ON faculty_member.MemberID = account_research.Acc_ID
                WHERE account_research.Res_ID =".$Res_ID;
                
        $query = $this->db->query($sql);
        if($query->num_rows() > 0);
            return $query->result_array();
        return 0;
    }
}